<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		#include("common/header.html")
		<link type="text/css" rel="stylesheet" href="/css/yejijilu.css" />
		<title></title>
	</head>
	<body>
		<header style="background: #005aab;" class="mui-bar mui-bar-nav head">
			<!--<span class="mui-icon mui-icon-back"></span>-->
			<h1 style="color: #FFFFFF; letter-spacing: 4px;" class="mui-title">业绩记录</h1>
			<!--<span class="mui-icon mui-icon-more"></span>-->
		</header>
		<nav style="background: #cccccc;" id="bottomx" class="mui-bar mui-bar-tab">
			<a class="mui-tab-item" href="/business/">
				<span class="mui-icon iconfont icon-qiyedengji-copy"></span><br>
				<span class="mui-tab-label">业绩登记</span>
			</a>
			<a class="mui-tab-item mui-active" href="/integral/">
				<span class="mui-icon iconfont icon-icon18"></span><br>
				<span class="mui-tab-label">积分兑换</span>
			</a>
			<a class="mui-tab-item" href="/v/center">
				<span class="mui-icon iconfont icon-gerenzhongxin"></span><br>
				<span class="mui-tab-label">个人中心</span>
			</a>
		</nav>
		<div class="mui-content">
			<div class="all_contains">
				<div class="selects">
					<input class="inpt" type="button" id="year"  placeholder="选择年份" onclick="yearPicker()"><span >年</span>
					<input class="inpt" type="button" id="quarter" placeholder="选择季度" onclick="quarterPicker()"><span>季度</span>
					<button id="btns" onclick="getList()">搜索</button>
				</div>
				<table>
					<thead>
					<tr>
						<th style="border-left: 0;">姓名</th>
						<th>类型</th>
						<th>金额/万</th>
						<th>贷款时间</th>
						<th>是否通过</th>
					</tr>
					</thead>
					<tbody id="list"></tbody>
				</table>
			</div>
		</div>
	</body>
	<script>
		mui.init();
		nav_tab();

		var date = new Date();
		var nowYear = date.getFullYear();
		var arr = new Array();
		for(var i = nowYear;i >= 1990;i--){
			var obj = {"value":i,"text":i};
			arr.push(obj);
		}

        function yearPicker(){
            var picker = new mui.PopPicker();
            picker.setData(arr)
            picker.show(function(item) {
                $("#year").val(item[0].value);
            })
        }
        function quarterPicker(){
            var picker = new mui.PopPicker();
            picker.setData([{value:"1",text:"1"},{value:"2",text:"2"},
			{value:"3",text:"3"},{value:"4",text:"4"}])
            picker.show(function(item) {
                $("#quarter").val(item[0].value);
            })
        }

        function because(id) {
			location.href = "/business/info/"+id;
        }

        $(function () {
            $("#year").val(nowYear);
            $("#quarter").val(1);
            getList();
        });

        function getList() {
            var year = $("#year").val();
            var quarter = $("#quarter").val();

            $.ajax({
                url: "/business/list",
                type: "post",
                dataType: "json",
                data: {"uid":$uid,"quarter":quarter,"year":year},
                success: function (r) {

                    console.log(r);

                    if (r.code == -1) {
                        return;
                    }

                    $("#list").html("");

                    var str = "";

                    $.each(r.data, function (n, value) {
                        str += '<tr onclick="because('+value.id+')">';
                        str += '<td style="border-left: 0;">'+value.name+'</td>';
                        str += '<td>'+value.product+'</td>';
                        str += '<td>'+value.money+'</td>';
                        str += '<td>'+value.loanTime+'</td>';
                        if(value.isOk == 0){
                            str += '<td>提交成功</td>';
						}else if(value.isOk == 1){
                            str += '<td>是</td>';
                        }else if(value.isOk == 2){
                            str += '<td>否</td>';
                        }
                        str += '</tr>';
                    });

                    $("#list").html(str);
                }
            });
        }
	</script>
</html>
